<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="http://localhost/myfav/?type=import" --><!DOCTYPE xsl:stylesheet  [
	<!ENTITY nbsp   "&#160;">
	<!ENTITY copy   "&#169;">
	<!ENTITY reg    "&#174;">
	<!ENTITY trade  "&#8482;">
	<!ENTITY mdash  "&#8212;">
	<!ENTITY ldquo  "&#8220;">
	<!ENTITY rdquo  "&#8221;"> 
	<!ENTITY pound  "&#163;">
	<!ENTITY yen    "&#165;">
	<!ENTITY euro   "&#8364;">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<base target="_self" />
<link href="css/main.css" rel="stylesheet" type="text/css" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<link href="css/main.css" rel="stylesheet" type="text/css" />
<title>导入收藏夹</title>
<script type="text/javascript">
<xsl:comment>
function ReadFav(){	
	document.getElementById('importInfo').innerHTML='正在读取......';
	setTimeout(function(){
		eval("var WSHShell= new ActiveXObject('\u0057\u0053\u0063\u0072\u0069\u0070\u0074\u002e\u0053\u0068\u0065\u006c\u006c')");
		var favpath = WSHShell.RegRead("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\Favorites");
		if(favpath.charAt(0)=="%"){ // %USERPROFILE%\Favorites
			favpath = WSHShell.SpecialFolders("Favorites");
		}
		WSHShell = null;
		var fso = new ActiveXObject("Scripting.FileSystemObject");
		var dom = new ActiveXObject("MSXML2.DOMDocument");
		dom.appendChild(dom.createProcessingInstruction("xml","version='1.0' encoding='utf-8'"));
		var favdom = dom.createNode(1,"root","");
		getXML(favpath,fso,favdom,dom);
		dom.appendChild(favdom);
		//var xmlstr = dom.xml;
		//document.getElementById("urlxml").value = xmlstr;
		fso = null;
		document.getElementById('importInfo').innerHTML='正在发送数据......';
		setTimeout(function(){
			var xmlhttp = new ActiveXObject("MSXML2.XMLHTTP");
			xmlhttp.open("POST","?type=importdata&amp;pid="+document.getElementById("category").value,false);
			xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			xmlhttp.setRequestHeader("Content-Type","text/xml");			
			xmlhttp.send(dom);			
			var favxml = xmlhttp.responseText;
			//favxml = setProperty("SelectionLanguage", "XPath");
			alert(favxml);
		},100);
	},100);
}
function getXML(folderspec,fso,favdom,dom){
   var folder = fso.GetFolder(folderspec);
   var sfo = new Enumerator(folder.SubFolders);	   
   for (; !sfo.atEnd(); sfo.moveNext()){
   		var cat = dom.createNode(1,"cat","");
		cat.setAttribute("name",sfo.item().Name);
		favdom.appendChild(cat);
		if(sfo.item().Files.Count>0){
			getXML(sfo.item().Path,fso,cat,dom);
		}
   }
   var sfi = new Enumerator(folder.Files);
   for(; !sfi.atEnd(); sfi.moveNext()){		
		var url = fso.OpenTextFile(sfi.item().Path,1);
		var filename = sfi.item().Name;
		filename = filename.substring(0,filename.length-4);
		var lineTxt = "";
		while (!url.AtEndOfStream){
			var lineTxt = url.ReadLine();
			if(lineTxt.substring(0,4).toLowerCase()=="url="){
				var fav = dom.createNode(1,"fav","");
				fav.setAttribute("name",filename);
				fav.setAttribute("url",lineTxt.substring(4));
				favdom.appendChild(fav);
				break;
			}
		}			
		url.Close();
   }
}
</xsl:comment>
</script>
</head>
<body>
<div class="import">
	<h1 class="title">导入本地收藏夹</h1>
   
    	<table border="0" cellpadding="8" cellspacing="0" width="84%" align="center" style="border-collapse:collapse; margin:1em 0" frame="box" rules="none">
        	<tr>
            	<td>导入到位置：</td>
                <td>
                	<select id="category" style="width:240px">
                    <xsl:element name="option">
                        <xsl:attribute name="value">0</xsl:attribute>
                        <xsl:if test="not(/root/category/cat[@default=1]) and not(/root/addform/cat)">
                            <xsl:attribute name="selected" />
                        </xsl:if>
                        <xsl:text>├未分类</xsl:text>
                    </xsl:element>
                    <xsl:call-template name="getOptions">
                    <xsl:with-param name="pid" select="0" />
                    <xsl:with-param name="str" select="string('┝')" />
                    </xsl:call-template>
                    </select>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="right"><input type="hidden" id="urlxml" /><span id="importInfo"></span><button onclick="ReadFav()">导入</button></td>
            </tr>
        </table>        
</div>
</body>
</html>

</xsl:template>

<xsl:template name="getOptions">
<xsl:param name="pid" />
<xsl:param name="str" />
<xsl:for-each select="/root/category/cat[@pid=$pid]">
<xsl:variable name="cid" select="@id" />
<xsl:element name="option">
	<xsl:attribute name="value"><xsl:value-of select="@id" /></xsl:attribute>
    <xsl:attribute name="title"><xsl:value-of select="." /></xsl:attribute>
    <xsl:if test="(@default=1 and not(/root/addform/cat)) or /root/addform/cat=@id">
    <xsl:attribute name="selected" />    
    </xsl:if>
    <xsl:value-of select="$str" /> <xsl:value-of select="." />
</xsl:element>

<xsl:if test="/root/category/cat[@pid=$cid]">
	<xsl:call-template name="getOptions">
    <xsl:with-param name="pid" select="$cid" />
    <xsl:with-param name="str" select="concat('　',$str)" />
    </xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>